package cs3343.project.family.testing;

import static org.junit.Assert.assertEquals;

import javax.swing.ImageIcon;

import org.junit.Test;

import cs3343.project.family.Character;
import cs3343.project.family.CharacterController;
import cs3343.project.family.ConfigManager;
import cs3343.project.family.GameController;

/**
 * The Class DiceTest.
 */
public class DiceTest {

	// test whether EndGame* all player 1200 esteem
	/**
	 * End game test1.
	 */
	@Test
	public void endGameTest1() {
	
		int numPlayer=3;
		int esteemPt=1200;

        String proimgPath = ConfigManager.IMAGE_PATH + "profilePic1" + ".jpg";
        String iconimgPath = ConfigManager.IMAGE_PATH + "char1" + ".jpg";
        String gproimgPath = ConfigManager.IMAGE_PATH + "gprofilePic1" + ".jpg";
        
        GameController gc= new GameController();
        CharacterController cc=gc.getCharacterController();
        cc.setNumOfPlayer(numPlayer);
   
        Character player = new Character("Tester",new ImageIcon(proimgPath),new ImageIcon(gproimgPath), new ImageIcon(iconimgPath));
        
        for (int i=0;i<numPlayer;i++){
        	cc.addPlayer(player, i);
        	cc.getPlayer(i).setEsteem(esteemPt);
        }

		boolean result=gc.gameWon();

		//boolean result=EndGame.f.isShowing();
		//boolean result=init.getGameFrame().isShowing();
		
		assertEquals(result,true);
	}
	
	/**
	 * End game test2.
	 */
	@Test
	public void endGameTest2() {
		
		int numPlayer=3;

        // players' general setting
		String proimgPath = ConfigManager.IMAGE_PATH + "profilePic1" + ".jpg";
        String iconimgPath = ConfigManager.IMAGE_PATH + "char1" + ".jpg";
        String gproimgPath = ConfigManager.IMAGE_PATH + "gprofilePic1" + ".jpg";
        GameController gc= new GameController();
        CharacterController cc=gc.getCharacterController();
        cc.setNumOfPlayer(numPlayer);
        
        Character player = new Character("Tester",new ImageIcon(proimgPath), new ImageIcon(gproimgPath),new ImageIcon(iconimgPath));
        
        // set first two player with >1000 esteem
        for (int i=0;i<2;i++){
        	cc.addPlayer(player, i);
        	cc.getPlayer(i).setEsteem(1320);
  
        }
        // set last character has esteem <1000
        cc.addPlayer(player, numPlayer-1);
        cc.getPlayer(numPlayer-1).setEsteem(100);
    
		boolean result=gc.gameWon();
		
		assertEquals(result,false);
		
	}
		

}
